package com.bjsxt.controller;

import com.bjsxt.pojo.PageA;
import com.bjsxt.pojo.Role;
import com.bjsxt.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @RequestMapping("/selectRoleController")
    public PageA<Role> selectRoleController(Integer page,Integer rows){
        return roleService.selectRoleSice(page, rows);
    }

    //添加角色
    @RequestMapping("/insertRoleController")
    public Integer insertRoleController(Role role,Integer[] mids){
        return roleService.insertRoleSice(role,mids);
    }

    //查询指定角色下的菜单
    @RequestMapping("/selectRoleMenu")
    public List<Integer> selectRoleMenu(Integer rid){
        return roleService.selectRoleMenuSice(rid);
    }

    //修改角色和表单
    @RequestMapping("/updateRole")
    public Integer updateRole(Role role,Integer[] mids){
        return roleService.deleteRole(role, mids);
    }

    //删除角色
    @RequestMapping("/deleteRole")
    public Integer deleteRole(Integer rid){
        return roleService.deleteRoleOne(rid);
    }

    //添加管理员查询
    @RequestMapping("/selectRoleName")
    public List<Role> selectRoleName(){
        return roleService.selectRoleNameSice();
    }
}
